//
//  MGTipsViewController.m
//  MortgageHelper
//
//  Created by zhangxiang on 16/12/12.
//  Copyright © 2016年 zhangxiang. All rights reserved.
//

#import "MGTipsViewController.h"
#import "MGConstFile.h"
#import "UINavigationController+FDFullscreenPopGesture.h"

#import "AppDelegate.h"

@interface MGTipsViewController ()

@property (weak, nonatomic) IBOutlet UIView *content_BgView;

@property (strong, nonatomic) IBOutlet UIView *resultMoreTimeView;

@property (strong, nonatomic) IBOutlet UIView *noResultView;

@property (strong, nonatomic) IBOutlet UIView *notify_View;

@property (weak, nonatomic) IBOutlet UIButton *ok_But;

@property (weak, nonatomic) IBOutlet UIButton *noResult_ok_But;

@property (weak, nonatomic) IBOutlet UIButton *cancel_But;

@property (weak, nonatomic) IBOutlet UIButton *openNotify_But;

@property (weak, nonatomic) IBOutlet UIView *noNetWork_View;

@property (weak, nonatomic) IBOutlet UIButton *tryAgian_But;

@property (weak, nonatomic) IBOutlet UIView *customer_BgView;

@property (weak, nonatomic) IBOutlet UIButton *cancelCustomer_But;
@property (weak, nonatomic) IBOutlet UIButton *okCustomer_But;

@property (weak, nonatomic) IBOutlet UIView *message_BgView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *hh;

@property (weak, nonatomic) IBOutlet UIButton *messageCancel_But;
@property (weak, nonatomic) IBOutlet UIButton *messagelook_But;
@property (weak, nonatomic) IBOutlet UILabel *weiyz;

@property (weak, nonatomic) IBOutlet UIView *massegeview;
@property (weak, nonatomic) IBOutlet UILabel *messageLabel;

//默认图标
@property (weak, nonatomic) IBOutlet UIImageView *topImage;
@property (weak, nonatomic) IBOutlet UIButton *konwBtn;


@end

@implementation MGTipsViewController

- (void)awakeFromNib {
    [super awakeFromNib];
    
    self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.6];
    [self customerUI];
    
    
}
-(void)customerUI{
    self.hh.constant = 400;
    switch (_tipsViewType) {
        case MGTipsViewTypeMoretime:
        {
            self.resultMoreTimeView.hidden=NO;
            [Util maskBorderAndRadiu:self.resultMoreTimeView];
        }
            break;
        case MGTipsViewTypeNoResult:
        {
            self.noResultView.hidden=NO;
            [Util maskBorderAndRadiu:self.noResultView];

        }
            break;
        case MGTipsViewTypeNoTiFy:
        {
            self.notify_View.hidden=NO;
            [Util maskBorderAndRadiu:self.notify_View];

        }
            break;
        case MGTipsViewTypeNoNetWork:
        {
            self.backgroundColor=[UIColor add_colorWithRGBHexString:@"f1f1f1"];
            self.content_BgView.hidden=YES;
            self.noNetWork_View.hidden=NO;
//            [Util maskBorderAndRadiu:self.tryAgian_But borderColor:[UIColor add_colorWithRGBHexString:@"999999"]];
            UITapGestureRecognizer *tap=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapSelfdismiss)];
            [self addGestureRecognizer:tap];
            
            
        }
            break;
        case MGTipsViewTypeCustomerAd:
        {
            self.content_BgView.hidden=YES;
            self.customer_BgView.hidden=NO;
            
            
        }
            break;
        case MGTipsViewTypeMessage:
        {
            self.content_BgView.hidden=YES;
            self.message_BgView.hidden=NO;
            self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
            [Util maskBorderAndRadiu:self.message_BgView];
            
            
        }
            break;
        case MGTipsViewTypewrz:
        {
            self.weiyz.text = @"成为按揭帮的认证用户";
            [self.noResult_ok_But setTitle:@"去认证" forState:UIControlStateNormal];
            self.checkFileTipsnoResult_Lab.hidden = YES;
            self.noResultView.hidden=NO;
            [Util maskBorderAndRadiu:self.noResultView];
            
        }
            break;
        case MGTipsViewTypeFxwsMoreTime:
        {
            self.weiyz.text = self.message1;
            [self.noResult_ok_But setTitle:@"去认证" forState:UIControlStateNormal];
            self.checkFileTipsnoResult_Lab.text = @"成为按揭帮的认证用户,每天赠送：";
            self.noResultView.hidden=NO;
            [Util maskBorderAndRadiu:self.noResultView];
            
        }
            break;
        case MGTipsViewTypeMessageOfFlase:
        {
            
            self.messageLabel.text = self.noResult_Lab.text;
            if (self.types) {
                self.hh.constant = 280;
                [self.konwBtn setTitle:@"返回" forState:UIControlStateNormal];
            }
            
//            self.topImage.image = [UIImage imageNamed:@"wuchaxunjieguo"];
            self.topImage.hidden = YES;
            self.massegeview.hidden=NO;
            [Util maskBorderAndRadiu:self.massegeview];
            
        }
            break;
        case MGTipsViewTypePgbgTime:
        {
//            self.weiyz.text = @"未认证用户每天最多查询1次";
            self.weiyz.text = self.message1;
            [self.noResult_ok_But setTitle:@"去认证" forState:UIControlStateNormal];
            self.checkFileTipsnoResult_Lab.text = @"成为按揭帮的认证用户,每天赠送：";
            self.noResultView.hidden=NO;
            [Util maskBorderAndRadiu:self.noResultView];
            
        }
            break;
            
        default:
            break;
    }
    
    [Util maskBorderAndRadiu:self.ok_But];
    [UIColor setgradientlayerStartPoint:CGPointMake(0, 0) startRGBHexString:@"cccccc" andEndPoint:CGPointMake(1, 0) endRGBHexString:@"ffd765" inView:self.ok_But];
    
    [Util maskBorderAndRadiu:self.noResult_ok_But];
    [UIColor setgradientlayerStartPoint:CGPointMake(0, 0) startRGBHexString:@"cccccc" andEndPoint:CGPointMake(1, 0) endRGBHexString:@"ffd765" inView:self.noResult_ok_But];
    
    [Util maskBorderAndRadiu:self.cancel_But];
    [Util maskBorderAndRadiu:self.konwBtn];
    [Util maskBorderAndRadiu:self.openNotify_But];
    [UIColor setgradientlayerStartPoint:CGPointMake(0, 0) startRGBHexString:@"cccccc" andEndPoint:CGPointMake(1, 0) endRGBHexString:@"ffd765" inView:self.openNotify_But];
    
    [Util maskBorderAndRadiu:self.cancelCustomer_But];
    [Util maskBorderAndRadiu:self.okCustomer_But];
    [Util maskBorderAndRadiu:self.customer_BgView];
    
//     [UIColor setgradientlayerStartPoint:CGPointMake(0, 0) startRGBHexString:@"cccccc" andEndPoint:CGPointMake(1, 0) endRGBHexString:@"ffd765" inView:self.okCustomer_But];
    

}

- (IBAction)closeTipsView:(UIButton *)sender {
    
    if (sender.tag==51) {
        
        [Util autoGo2NotificationsSetting];
    }
    if (sender.tag==62) { //生成客户动态
        if (_customerAdBlock) {
            _customerAdBlock();
        }
    }
    if (sender.tag==72) {  // 查看新的消息 推送
        if (_lookMessageBlock) {
            _lookMessageBlock();
        }
    }
    if (_tipsViewType == MGTipsViewTypewrz || _tipsViewType == MGTipsViewTypeFxwsMoreTime|| _tipsViewType == MGTipsViewTypePgbgTime) {
        if (self.wrzBlock) {
            self.wrzBlock();
        }
    }
    
    [self removeself];
}

- (IBAction)tryAgain:(id)sender {
    if (_tryAgain) {
        _tryAgain();
    }
    
    [self removeself];
}
- (IBAction)konw:(id)sender {
    
    [self removeself];
}

-(void)removeself{
    
    [UIView animateWithDuration:0.3 animations:^{
        self.alpha = 0.0;
        [self removeFromSuperview];
    }];

    
}
-(void)tapSelfdismiss{
    [self tryAgain:nil];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
